from pages.basePage3 import BasePage
from config.setting import host_port
# 定位层
class Elment_trading_record(BasePage):
    def __init__(self):
        BasePage.__init__(self)
        self.driver.get(f"http://{host_port}/SharedParkingPlace/property/index.html")
    # 定位账户管理
    def elment_zhanghuguanli(self):
        return self.driver.find_element_by_xpath('/html/body/div[2]/div[1]/div/div[3]/div[1]/div[1]')

    # 定位交易记录
    def elment_trading(self):
        return self.driver.find_element_by_xpath('//div[@id="_easyui_tree_7"]/span[3]')

    # 定位表单
    def elment_biaodan(self):
        a = self.driver.find_element_by_xpath('//div[@id="testIframe"]/div[2]/div[2]/div/iframe')
        return a
#定位开始时间
    def elment_start(self):
        return self.driver.find_element_by_xpath('//input[@id="beginTime"]')
        # 定位结束时间
    def elment_end(self):
        return self.driver.find_element_by_xpath('//input[@id="endTime"]')
# 定位查询
    def elment_chaxun(self):
        return self.driver.find_element_by_xpath('//span[@class="textbox-addon textbox-addon-right"]')
# 定位断言文本框
    def elment_assert(self):
        return self.driver.find_element_by_xpath('//tr[@id="datagrid-row-r1-2-0"]/td[2]/div')
# 操作层
class Option_trading(Elment_trading_record):
    def __init__(self):
        Elment_trading_record.__init__(self)

    #     点击用户管理
    def click_yonghuguanli(self):
        self.elment_zhanghuguanli().click()

    #     点击交易信息
    def click_property(self):
        self.elment_trading().click()

    #     切换表单
    def get_biaodan(self):
        a = self.elment_biaodan()
        return self.driver.switch_to.frame(a)
    # 输入开始时间
    def input_start(self,starttime):
        return self.elment_start().send_keys(starttime)

    # 输入结束时间
    def input_end(self, endtime):
        return self.elment_end().send_keys(endtime)
    # 点击查询
    def click_chaxun(self):
        self.elment_chaxun().click()
    # 获取断言文本
    def option_text(self):
        return self.elment_assert().text
# 业务层
class Apply_trading(Option_trading):
    def __init__(self):
        Option_trading.__init__(self)
    def select_rrading(self,starttime,endtime):
        self.click_yonghuguanli()
        self.click_property()
        self.get_biaodan()
        self.input_start(starttime)
        self.input_end(endtime)
        self.click_chaxun()
        b=self.option_text()

        return b
if __name__ == '__main__':
    Apply_trading().select_rrading('2021/06/26','2021/06/27')


